package derek.sun;

import javax.swing.JTree;
import javax.swing.tree.DefaultMutableTreeNode;

public class MyTree extends JTree {
	private static final long serialVersionUID = 1L;
	DefaultMutableTreeNode firstClassNode;

	public MyTree(DefaultMutableTreeNode top) {
		super(top);
		firstClassNode = top;
	}

	public DefaultMutableTreeNode addSubNode(String tmp) {
		DefaultMutableTreeNode c = new DefaultMutableTreeNode(tmp);
		firstClassNode.add(c);
		return c;
	}

	public DefaultMutableTreeNode addSubNode(String tmp, String url) {
		DefaultMutableTreeNode c = new DefaultMutableTreeNode(tmp);
		c.setUserObject(url);
		System.out.println("User's Object" + c.getUserObject().toString());
		firstClassNode.add(c);
		return c;
	}

	public void addSubNode(DefaultMutableTreeNode root,
			DefaultMutableTreeNode node) {
		root.add(node);
	}

	public void addSubNode(DefaultMutableTreeNode root,
			DefaultMutableTreeNode node, String url) {
		node.setUserObject(url);
		System.out.println("User's Object" + node.getUserObject().toString());
		root.add(node);
	}

}
